package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.view.entity.MenuEntity;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.recyclerview.adapter.PageRecycleAdapter;

import java.util.ArrayList;
import java.util.List;

public class MenuPublishPopAdapter extends PageRecycleAdapter<MenuEntity> {

    public MenuPublishPopAdapter(Context context, List<MenuEntity> datas) {
        super(context, R.layout.item_publish_pop_menu, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, MenuEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView tv = holder.itemView.findViewById(R.id.tv);
        if (entity.getName().equals("机械出租")
                ||entity.getName().equals("设备出租")
                ||entity.getName().equals("车辆出租")
                ||entity.getName().equals("房产出租")
                ||entity.getName().equals("土地出租")
                ||entity.getName().equals("工厂出租")
                ||entity.getName().equals("农机出租")){
            tv.setBackground(context.getResources().getDrawable(R.drawable.shape_publish_yellow_pop));
            tv.setTextColor(context.getResources().getColor(R.color.color_FFC000));
        }else {
            tv.setBackground(context.getResources().getDrawable(R.drawable.shape_publish_pop));
            tv.setTextColor(context.getResources().getColor(R.color.color_main));
        }

    }

    @Override
    public int getCount() {
        return count;
    }
    public void setCount(int count) {
        this.count = count;
    }
    public void setDatas(List<MenuEntity> datas) {
        this.datas = datas;
        if (this.datas == null) {
            this.datas = new ArrayList<>();
            isShowEmptyView = true;
        } else {
            isShowEmptyView = false;
        }
        notifyDataSetChanged();
    }
}
